<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.cap.bts.framework.usermgnt.constant.EmployeeStatus"%>    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>会员卡配送</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<link rel="stylesheet" type="text/css" href="${csspath }/style_l.css"/>
<script type="text/javascript" src="${jspath }/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.blockUI.js?l"></script>
<script type="text/javascript" src="${jspath }/public.js"></script>
<script type="text/javascript" src="${jspath }/jquery.selectAll.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
<script type="text/javascript" src="${jspath}/load_layer.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath}/jquery.alerts.css" />

<link rel="stylesheet" type="text/css"
	href="${webcontext}/css/validationEngine.jquery.css" />
<script src="${jspath}/jquery/validate/jquery.validationEngine.js"
	type="text/javascript"></script>
<script src="${jspath}/jquery/validate/jquery.validationEngine-zh.js"
	type="text/javascript"></script>
	<script type="text/javascript"
	src="${webcontext}/javascript/jquery/jquery.ui.draggable.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js?"></script>
<style type="text/css">
.formError .formErrorContent {
    -moz-border-radius: 6px 6px 6px 6px;
    -moz-box-shadow: 0 0 6px #000000;
    background: none repeat scroll 0 0 #EE0101;
    border: 2px solid #DDDDDD;
    color: #FFFFFF;
    font-family: tahoma;
    font-size: 11px;
    padding: 4px 10px;
    width: 100px;
} 
</style>
<script type="text/javascript">
var myHeight = 0;
$(function(){
	
	$("#search_form").validationEngine(
			{
             promptPosition:"topLeft",
             success:false,
             validationEventTriggers:"blur",
             scroll : false,
			 failure:function(){} 
	});
	var today = new Date();   
	var day = today.getDate();   
	var month = today.getMonth() + 1;   
	var year = today.getFullYear();    
	var date = year + "-" + month + "-" + day;
	var startDate = $("#startDate").val();	
	if(startDate == "" || startDate == undefined || startDate == null){
		document.getElementById("startDate").value = date;
	}
	var endDate = $("#endDate").val();	
	if(endDate == "" || endDate == undefined || endDate == null){
		document.getElementById("endDate").value = date;
	}

	
});


function search() {
	var startDate = $("#startDate").val();
	var endDate = $("#endDate").val();	
	if(startDate == "" || startDate == undefined || startDate == null
			||endDate == "" || endDate == undefined || endDate == null){
		jAlert('请输入发货起止时间', '提示');
	}else{
		search_form.action="${webcontext}/crmdp/dealer/logistic/toQueryLogisitcPage";
		document.getElementById("search_form").submit();
	}
}
function create() {
	search_form.action="${webcontext}/crmdp/dealer/logistic/toCreateLogisitcPage";
	document.getElementById("search_form").submit();
}
function upload() {
	search_form.action="${webcontext}/crmdp/dealer/logistic/toUploadLogisitcPage";
	document.getElementById("search_form").submit();
}
function printPage() {
	var startDate = $("#startDate").val();
	var endDate = $("#endDate").val();	
	if(startDate == "" || startDate == undefined || startDate == null
			||endDate == "" || endDate == undefined || endDate == null){
		jAlert('请输入发货起止时间', '提示');
	}else{
		search_form.action="${webcontext}/crmdp/dealer/logistic/toPrintLogisticPage";
	}
	document.getElementById("search_form").submit();
}
function deleteLogistic(id){
	jConfirm("确认删除记录？","确认提示",function(result){
		if(result == true){	
			location.href="${webcontext}/crmdp/dealer/logistic/toDeleteLogisitcPage/"+id;
		}
	});
}

function export2Excel() {
	var startDate = $("#startDate").val();
	var endDate = $("#endDate").val();	
	if(startDate == "" || startDate == undefined || startDate == null
			||endDate == "" || endDate == undefined || endDate == null){
		jAlert('请输入发货起止时间', '提示');
	}else{
		//search_form.action="${webcontext}/crmdp/dealer/logistic/toQueryLogistic";
/*		var data = {transactionStartDate: $("#startDate").val(),
					transactionEndDate : $("#endDate").val(),
					orderNum : $("#orderNum").val(), 
					orderStatus : $("#orderStatus").val(),
					expressCom : $("#expressCom").val(),
					expressNum : $("#expressNum").val()
		}
*/
		var form = $("<form method='post'>");
		form.append($("#search_form").html());
		var requestLocation = location.origin+"/task/logisticDataExport/export";
		console.log(location.origin);
		form.attr("action",requestLocation);
		form.submit();
/*		$.ajax({
			type: "POST",
			url: requestLocation,
			data: data,
			//dataType: "json",
			//contentType : 'application/json',
			success: function(data){
				alert('success');
			},
			error: function(){
				alert('导出失败');
			}
		});
		*/
	}
}

</script> 
</head>
<body>
		<!-- content -->
	<div id="content">
		    <div class="spliter h_5"></div>
			<div class="page_info"></div>
			<div class="spliter h_5"></div>
	<div id="row">
	<form:form  class="form-horizontal" id="search_form" method="post" modelAttribute="dto">
			<div class="row">
				<div class="form-group">
					<label class="col-sm-4 control-label" for="startDate">发货日期</label>
					<div class="col-sm-3">
						<input name="transactionStartDate" class="form-control input-sm validate[length[0,100]] date" id="startDate" type="text"
							 value="${dto.transactionStartDate}" />
					</div>
					<label class="col-sm-2 control-label" for="endDate">结束日期</label>
					<div class="col-sm-3">
						<input  name="transactionEndDate" class="form-control input-sm validate[length[0,100]] date" id="endDate" type="text" 
						 value="${dto.transactionEndDate}" />
					</div>
				</div>
			</div>
			<div class="row">
				<div class="form-group">
					<label class="col-sm-4 control-label" for="orderNum">订单编号</label>
					<div class="col-sm-3">
						<input name="orderNum" class="form-control input-sm" id="orderNum" type="text" value="${dto.orderNum}"/>
					</div>
					<label for="orderStatus" class="col-sm-2 control-label">订单状态</label>
					<div class="col-sm-3">
						<form:select path="orderStatus" cssClass="form-control input-sm">
							<form:option value="">全部</form:option>
							<form:option value="0">在途</form:option>
							<form:option value="1">已接收</form:option>
						</form:select>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="form-group">
					<label class="col-sm-4 control-label" for="expressCom">物流公司</label>
					<div class="col-sm-3">
						<input name="expressCom" class="form-control input-sm" id="expressCom" type="text" value="${dto.expressCom}"/>
					</div>
					<label class="col-sm-2 control-label" for="expressNum">物流单号</label>
					<div class="col-sm-3">
						<input  name="expressNum" class="form-control input-sm" id="expressNum" type="text" value="${dto.expressNum}"/>
					</div>
				</div>
			</div>
			<div style="text-align: center; margin-top: 10px;">
				<button type="button" class="btn btn-success" style="width: 100px;" onclick="search()"><i class="glyphicon glyphicon-search" style="color:#FFFFFF"></i>&nbsp;查询</button>
				<button type="reset" class="btn btn-success" style="width: 100px;"><i class="glyphicon glyphicon-trash" style="color:#FFFFFF"></i>&nbsp;重置</button>
				<button type="button" class="btn btn-success" style="width: 100px;" onclick="create()"><i class="glyphicon glyphicon-plus" style="color:#FFFFFF"></i>&nbsp;新建 </button>
				<button type="button" class="btn btn-success" style="width: 100px;" onclick="upload()"><i class="glyphicon glyphicon-upload" style="color:#FFFFFF"></i>&nbsp;批量上传</button>
				<button type="button" class="btn btn-success" style="width: 100px;" onclick="printPage()"><i class="glyphicon glyphicon-print" style="color:#FFFFFF"></i>&nbsp;打印 </button>
				<button type="button" class="btn btn-success" style="width: 100px;" onclick="export2Excel()"><i class="glyphicon glyphicon-download" style="color:#FFFFFF"></i>&nbsp;导出</button>
			</div>
			<!-- /search_div -->
			<div class="spliter h_5"></div>
			<div class="page_info"></div>
			<div class="spliter h_10"></div>
			<!-- data_div -->
			<div id="dataTable" class="data_div">
			<table id="table" class="table">
				<tr>
					<th width="6%">门店编号</th>
					<th width="7%">门店名称</th>
					<th width="6%">订单编号</th>
					<th width="7%">商品名称</th>
					<th width="7%">实发数量</th>
					<th width="8%">发货日期</th>
					<th width="8%">预计到货</th>
					<th width="6%">物流公司</th>
					<th width="7%">物流单号</th>
					<th width="7%">实收数量</th>
					<th width="8%">收货日期</th>
					<th width="5%">状态</th>
					<th width="5%">修改</th>
					<th width="5%">删除</th>
				</tr>
            	<core:forEach items="${resultList}" var="logisticResultsDto">
					<tr>
                        <td class="text-left">${logisticResultsDto.dealerNo}</td>
                        <td class="text-left">${logisticResultsDto.dealerName}</td>
                        <td class="text-left">${logisticResultsDto.orderNo}</td>
                        <td class="text-left">${logisticResultsDto.cardName}</td>
                        <td class="text-right">${logisticResultsDto.shipAmount}</td>
                        <td class="text-left">${logisticResultsDto.shipDate}</td>
                        <td class="text-left">${logisticResultsDto.estimatedArriveDate}</td>
                        <td class="text-left">${logisticResultsDto.expressCom}</td>
                        <td class="text-left">${logisticResultsDto.expressNo}</td>
                        <td class="text-right">
                        <core:choose>
                        <core:when test="${logisticResultsDto.receiveAmount == logisticResultsDto.shipAmount}">
                        ${logisticResultsDto.receiveAmount}
                        </core:when>
                        <core:when test="${logisticResultsDto.receiveAmount < logisticResultsDto.shipAmount}">
                        <b style="color:red">${logisticResultsDto.receiveAmount}</b>
                        </core:when>
                        </core:choose>
                        </td>
                        <td class="align_r">${logisticResultsDto.receiveDate}</td>
                        <td class="align_m">${logisticResultsDto.status}</td>
                        <td class="align_m">
                        <core:choose>
                        <core:when test="${logisticResultsDto.status == '在途'}">
                        <a href="${webcontext}/crmdp/dealer/logistic/toEditLogisitcPage/${logisticResultsDto.id};">修改</a>
                        </core:when>
                        <core:when test="${logisticResultsDto.status == '已接收'}">
                        <s><i></i></s>
                        </core:when>
                        </core:choose>
                        </td>
                        <td class="align_m">
                        <core:choose>
                        <core:when test="${logisticResultsDto.status == '在途'}">
                        <a href="javascript:deleteLogistic(${logisticResultsDto.id});">删除</a>
                        </core:when>
                        <core:when test="${logisticResultsDto.status == '已接收'}">
                        <s><i></i></s>
                        </core:when>
                        </core:choose>
                        </td>
                    </tr>
                 </core:forEach>
			</table>
		</div>
			<!-- /data_div -->
            <!-- page_div -->
			<div class="page_div">
			    <%@include file="../common/page.jsp"%>
			</div>
			<!-- /page_div -->
		</form:form>
		</div>
		<!-- /wrap -->
		</div>
	<!-- /content -->
	</body>
	</html>
		